using UnityEngine;
using UnityEditor.IMGUI.Controls;
using UnityEditor;
using System;

namespace TCC.Framework
{
    /// <summary>
    /// 表格表头（列标题）
    /// </summary>
    public class TableColumnHeader<T> : MultiColumnHeader where T:class,new()
    {
        /// <summary>
        /// 绘制单个列标题方法
        /// </summary>
        public Action<Rect, TableColumn<T>, int> DrawHeaderMethod;
        public TableColumnHeader(MultiColumnHeaderState state):base(state)
        {

        }

        /// <summary>
        /// 单击列标题时展开的上下文菜单
        /// </summary>
        /// <param name="menu">上下文菜单</param>
        protected override void AddColumnHeaderContextMenuItems(GenericMenu menu)
        {
            base.AddColumnHeaderContextMenuItems(menu);
        }

        /// <summary>
        /// 单击列标题时
        /// </summary>
        /// <param name="column">列标题数据</param>
        /// <param name="columnIndex">列标题索引</param>
        protected override void ColumnHeaderClicked(MultiColumnHeaderState.Column column, int columnIndex)
        {
            base.ColumnHeaderClicked(column, columnIndex);
        }

        /// <summary>
        /// 定义单个列标题GUI
        /// </summary>
        /// <param name="column">列标题数据</param>
        /// <param name="headerRect">列标题矩形</param>
        /// <param name="columnIndex">列标题索引</param>
        protected override void ColumnHeaderGUI(MultiColumnHeaderState.Column column, Rect headerRect, int columnIndex)
        {
            TableColumn<T> tableColumn = column as TableColumn<T>;
            if (DrawHeaderMethod != null)
            {
                DrawHeaderMethod.Invoke(headerRect, tableColumn, columnIndex);
            }
            else
                base.ColumnHeaderGUI(column, headerRect, columnIndex);
        }
    }
}

